<template>
    <div class="com-cnt">
        <div style="height:90%;font-size:14px;color:#666;line-height:50px;text-align:center;padding-bottom:45px;overflow-y:scroll"> <img src="@/assets/imgs/acti0629.jpg" /> </div>
        <div @click="applyDo" class="btn-fix">立即报名</div>
    </div>
</template>

<script>
    import axios from 'axios'
    import Qs from 'qs'
    import { maskTips, maskCallback } from '@/assets/js/dom'
    export default {
        name: 'applyPage', 
        data ( ) {
            return {
                userid: (function(){
                    return localStorage.getItem('userid') ? localStorage.getItem('userid') : ''
                })()                 
            }
        }, 
        mounted ( ) {
            let self = this
            maskCallback(function(){
                self.$router.push('/center?source=3')
            }, 'comp-mask-btnAleft-acti','comp-mask-btnAright')
            maskCallback(function(){
                self.$router.push('/')
            }, 'comp-mask-btnAleft-suc-acti') 
        },      
        methods: {   
            applyDo ( ) {
                let self = this            
                axios({
                    url: '/xshk/f/active/user/add',
                    method:'post',
                    headers:{'Content-Type':'application/x-www-form-urlencoded'},
                    data: Qs.stringify({
                        'type': 1,
                        'userid':  self.userid
                    })
                }).then( res => {self.handleApplySucc( res )}).catch( err => {self.handleGetDataFail( err )}) 
            },
            handleApplySucc ( res ) {
                res = res.data
                if ( res && res.code == 0 ) {
                    maskTips({id:"axios-tips-suc",title:'温馨提示',btnCls: 'comp-mask-btnAleft-suc-acti',btnTxt:'确认',txt:'稍后工作人员将与您电话联系，请您保持电话畅通！'}) 
                }else{
                    //未登录                 
                    maskTips({id:"axios-tips-fail_"+ new Date().getTime(),title:'温馨提示',btnCls: 'comp-mask-btnAleft-acti',btnTxt:'确认',btnTxt2:'取消',txt: res.message })                    
                }
            },            
            handleGetDataFail ( err ) {
                console(err)
                maskTips({id:"axios-tips-fail",txt:'网络通信失败!'})
            }                   
        }         
    }
</script>

<style lang="stylus" scoped>
.com-cnt
    width 100%
    height 100% 
    overflow hidden
    .btn-fix 
        width 100%
        height 45px
        line-height 45px
        text-align center 
        font-size 16px
        color #fff
        background-color #ffd351
        position fixed
        left 0
        bottom 0
        
.com-cnt img 
    width 100%
    display block
    
    
</style>